#include "LogAction.h"
/*
<?xml version="1.0" encoding="utf-8"?>
<Request>	
<Security ip="192.168.1.103" date="1365926935000" digitalseal="5dade202580702f0826a74a27163fff2"/>
<Service business="AAS" function="saveMtLog"/>	
<RequestInfo querytype="Other" page="" pagesize="">	
<SaveMtLogInfo uid="root" token="4c9fb301cbb9a39822922388f30cf5c3" 
item="" type="" targetid="" targetname="DV_0001900_CSHP@test" targetvalue="UDP" description=""/>
</RequestInfo>
</Request>

<?xml version="1.0" encoding="UTF-8"?>
<Result><ResultInfo resultcode="200" errormessage="OK"/>
<Service business="AAS" function="saveMtLog"/>
<ResultData querytype="Other"/>
</Result>

*/

LogReqReader::LogReqReader(void)
{
}


LogReqReader::~LogReqReader(void)
{
}

int LogReqReader::read(CommRequest& req)
{
	LogReq& logReq = static_cast<LogReq&>(req);
	TiXmlElement* pChild = m_pRootEle->FirstChildElement("RequestInfo");
	const char* strType = pChild->Attribute("querytype");
	TiXmlElement* pChild2 = pChild->FirstChildElement("SaveMtLogInfo");
	logReq.uid = pChild2->Attribute("uid");

	return 0;
}

LogRepWriter::LogRepWriter(void)
{
}


LogRepWriter::~LogRepWriter(void)
{
}
int LogRepWriter::doWrite(const CommReply& rep,string& reply)
{
	const LogRep& logRep = static_cast<const LogRep&>(rep);

	TiXmlElement ResultInfoEle("ResultInfo");
	ResultInfoEle.SetAttribute("resultcode",logRep.status);
	ResultInfoEle.SetAttribute("errormessage","OK");

	m_pRootNode->InsertEndChild(ResultInfoEle);

	TiXmlElement ServiceEle("Service");
	ServiceEle.SetAttribute("business","AAS");
	ServiceEle.SetAttribute("function","saveMtLog");
	m_pRootNode->InsertEndChild(ServiceEle);

	TiXmlElement ResultDataEle("ResultData");
	ResultDataEle.SetAttribute("querytype","other");

	TiXmlNode* pResultDataNode = m_pRootNode->InsertEndChild(ResultDataEle);

	reply << *m_pDoc;

	return 0;
}
